package com.mad.gdrapps;


import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;


/**
 * A list view example where the 
 * data for the list comes from an array of strings.
 */
public class TopicsScr extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Use an existing ListAdapter that will map an array
        // of strings to TextViews
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, topics));
        getListView().setTextFilterEnabled(true);
    }

    private String[] topics = {"History of Gurudwara",
			   "Guru Harkrishan Sahib ji",
			   "Guru Granth Sahib ji",
			   "Being a Sikh",
			   "Gallery",
			   "Guidelines of visiting Gurudwaras",
			   "Show Location"} ; 



    private String[] topicsToClass = {"com.mad.gdrapps.HistoryOfGdrScr",
    							      "com.mad.gdrapps.AboutGuruScr",
    							      "com.mad.gdrapps.SGGSScr",	
    							      "com.mad.gdrapps.BeingASikhScr",
    							      "com.mad.gdrapps.GalleryGdrScr",
    							      "com.mad.gdrapps.GuidelinesScr",
    							      "com.mad.gdrapps.ShowLocationScr"} ; 
    
    
    // @todo get the itemps from a properties/XML file use the Helper load methods	
    

    @Override public void onListItemClick(ListView l, View v, int position, long id) {
        
        Log.d("BANGLA", "Item clicked: " + id);
        Log.d("BANGLA", "Position: " + position);
        Log.d("BANGLA", "Topic Clcked: " + topics[position]);
 
        Intent intent = null;
        try {
	    
           Log.d("BANGLA", "Class invoked: " + topicsToClass[position]);  
	       
           intent = new Intent(getApplicationContext(), Class.forName(topicsToClass[position]));
	       
           Log.d("BANGLA", "1");

           if (position == 6) {
        		
        	  // Intent intent = new Intent(getApplicationContext(), BasicLevel.class);
        	   Log.d("BANGLA", "2");
	
        		Bundle b = new Bundle(1);
        		 Log.d("BANGLA", "3");

        		b.putString("KEY_LATT","28.626343");
        		 Log.d("BANGLA", "4");

        		b.putString("KEY_LONG", "77.208009");
        		 Log.d("BANGLA", "5");

        		intent.putExtra("KEY_COORD_BUNDLE",b);
        		 Log.d("BANGLA", "6");

           }
           
        } catch (Exception cEx){
        	 
        	Log.d("BANGLA", "7");
        	Log.e("BANGLA",cEx.getMessage());
        	cEx.printStackTrace();
        	
        }
        
          // Bundle b = new Bundle(1);
          // b.putString(QUESTION_NO_KEY, String.valueOf(currentQuestion));
          // intent.putExtra(ACTIVITY_BUNDLE_KEY,b);
        
    	Log.d("BANGLA", "8");

        startActivity(intent);
		
      
    }
    
    	
}